#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "QMetaEnum"
#include "QFileDialog"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->file_menu,&QMenu::triggered,this,&MainWindow::OnActionTriggter);
    connect(ui->edid_menu,&QMenu::triggered,this,&MainWindow::OnActionTriggter);

}

MainWindow::~MainWindow()
{
    delete ui;

}

void MainWindow::OnActionTriggter(QAction *act){
    QMetaEnum me=QMetaEnum::fromType<ActKind::ActionKind>();
    bool ok;
    int k=me.keyToValue(act->text().toStdString().c_str(),&ok);
    if(!ok) return;
    switch(static_cast<ActKind::ActionKind>(k)){
    case ActKind::ActionKind::Newfile:
        OnNewfile();
        break;
    case ActKind::ActionKind::Openfile:

        break;
    case ActKind::ActionKind::savefile:

        break;
    case ActKind::ActionKind::saveasfile:

        break;
    case ActKind::ActionKind::Quit:

        break;
    case ActKind::ActionKind::undo:

        break;
    case ActKind::ActionKind::cut:

        break;
    case ActKind::ActionKind::Copy:

        break;
    case ActKind::ActionKind::paste:

        break;
    case ActKind::ActionKind::SelectAll:

        break;
    }
}

void MainWindow::OnNewfile(){

}

void MainWindow::MaybeSave(){

}
